<%@page import="org.omg.CORBA.TIMEOUT"%>
<%@page import="databaseLayer.StatisticsLookUp" %>
<%@page import="databaseLayer.MoviesLookUp" %>
<%@page import="statistics.*" %>

    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    
    <% HouseStatistics[] hStatistics = StatisticsLookUp.getHouseStatistics();
       int numberOfHouse;
       if(hStatistics != null)
           numberOfHouse = hStatistics.length;
       else
           numberOfHouse = 0;           
    %>
    <script type="text/javascript">
      google.load("visualization", "1", {packages:["corechart"]});
      google.setOnLoadCallback(drawChart2);
      
      function drawChart2() {
        var data = new Array();
        var options = new Array();
        var chart = new Array();
        <% for(int i=0; i<numberOfHouse; i++){ %>  
            data[<%= i %>] = google.visualization.arrayToDataTable(       
            [
            ['State', 'Amount'],
            ['Bought',     <%= hStatistics[i].getBought() %>],
            ['Available',      <%= hStatistics[i].getAvailable() %>],
            ['Unavailable',  <%= hStatistics[i].getUnavailable() %>],
            ]
            );

            options[<%= i %>]  = {
                title: 'House<%= i+1 %>'
            };
            
            chart[<%= i %>] = new google.visualization.PieChart(document.getElementById('hchart_div' + [<%= i %>]));
            chart[<%= i %>].draw(data[<%= i %>], options[<%= i %>]);
        <% } %>
      }
    </script>
    
    <% for(int i=0; i<numberOfHouse; i++){ %>
    <div id="<%= "hchart_div" + i %>" style="width: 900px; height: 500px;"></div>
    <p>Gross: <%= hStatistics[i].getGross() %></p>
    <hr />
    <% } %>